

package cn.shengchao.controler.query;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.shengchao.examstar.dict.acl.ports.repositories.IExamStarDictRepository;
import cn.shengchao.examstar.dict.acl.ports.message.DictDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "字典")
@Slf4j
@RestController
@CrossOrigin("${project.cross-origin}")
@RequestMapping("/api/${project.version}/dict")
public class ExamStarDictQueryController {

    @Autowired
    private IExamStarDictRepository iExamStarDictRepository;

    @SaIgnore
    @Operation(summary = "获取字典", description = "获取字典")
    @RequestMapping("{code}")
    public List<DictDto> list(@PathVariable String code, @RequestParam(required = false) Long pid) {
        if (!code.equals("test_type") && code != null && pid == null) {
            pid = Long.valueOf(code);
        }
        return iExamStarDictRepository.getList(code, pid);
    }
}
